/**
 * 	 Copyright (c) 2008, 2009 Lukas Zaruba
 * 
 *   This file is part of UniAnalyzer (Universal Analyzer).
 *
 *   UniAnalyzer is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   UniAnalyzer is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with UniAnalyzer. If not, see <http://www.gnu.org/licenses/>.
 */

package net.zarubsys.unianalyzer.dataminers.lpt.internal.provider;


import org.apache.log4j.Logger;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;

/**
 * LptProviderFactory
 *
 * @author  &lt;A HREF=&quot;mailto:lukas.zaruba@media-solutions.cz&quot;&gt;Lukas Zaruba&lt;/A&gt;, MEDIA SOLUTIONS CZECH REPUBLIC Ltd.
 * @version $Revision$ $Date$
 */
public class LptProviderFactory {
	
	private static final LptProviderFactory instance = new LptProviderFactory();
	private static final Logger log = Logger.getLogger(LptProviderFactory.class);
	
	private LptProviderFactory() {
	}
	
	public static LptProviderFactory getInstance() {
		return instance;
	}
	
	public ILptProvider getLptProvider() {
		IConfigurationElement[] configElems = Platform.getExtensionRegistry().getConfigurationElementsFor("net.zarubsys.unianalyzer.dataminers.lpt.internal.lptPortProvider");
		int count = configElems.length;
		if (count != 1) {
			log.error("Invalid count of extensions (" + count + ") for net.zarubsys.unianalyzer.dataminers.lpt.internal.lptPortProvider.");
			return null;
		}
		try {
			ILptProvider provider = (ILptProvider) configElems[0].createExecutableExtension("class");
			return provider;
		} catch (CoreException e) {
			log.error("Cannot load extension for net.zarubsys.unianalyzer.dataminers.lpt.internal.lptPortProvider.", e);
		}
		return null;
	}
}


/*
 * $Log$
 */